<template>
    <div class="app-container">
        <levelbar></levelbar>
        <el-form ref="form" :model="form" class="app-content" label-width="150px" label-position="right">
            <div class="box" v-loading = 'loading'>
                <div class="appTitle">查看</div>
                <div class="sales-title">
                    <span class="tip"></span>
                    <span class="title">基础信息</span>
                </div>
                <div class='chart-trend'>
                    <el-form-item label="收费项：">
                        <span>{{name}}</span>
                    </el-form-item>
                    <el-form-item label="备注：">
                        <span>{{form.sRemark}}</span>
                    </el-form-item>
                </div>
                <div class="sales-title" v-if="this.$route.params.id == '123554'">
                    <span class="tip"></span>
                    <span class="title">会员特权试用设置</span>
                </div>
                <div class='chart-trend' v-if="this.$route.params.id == '123554'">
                    <el-row :gutter="21">
                        <el-col :span="7">
                            <el-form-item label="错题本">
                                <span>{{form.sWrongCount}}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="智能学习">
                                <span>{{form.sSituationCount}}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="学情报告">
                                <span>{{form.sStudyCount}}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <div class="sales-title">
                    <span class="tip"></span>
                    <span class="title">标准底价/元</span>
                </div>
                <div class='chart-trend'>
                    <el-row :gutter="21">
                        <el-col :span="7">
                            <el-form-item label="月收">
                                <span>{{form.sBasePrice[0].price | moneySwitch}}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="半年收">
                                <span>{{form.sBasePrice[1].price | moneySwitch}}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="年收">
                                <span>{{form.sBasePrice[2].price | moneySwitch}}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <div class="sales-title">
                    <span class="tip"></span>
                    <span class="title">市场指导价/元</span>
                </div>
                <div class='chart-trend'>
                    <el-row :gutter="21">
                        <el-col :span="7">
                            <el-form-item label="月收">
                                <span>{{form.sMarketPrice[0].price | moneySwitch}}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="半年收">
                                <span>{{form.sMarketPrice[1].price | moneySwitch}}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="年收">
                                <span>{{form.sMarketPrice[2].price | moneySwitch}}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <div class="sales-title">
                    <span class="tip"></span>
                    <span class="title">B端采购优惠 <span class="b-text-last">( 注:折扣为10，B端采购价=标准底价；折扣不为10，B端采购价=标准底价*折扣。)</span></span>
                </div>
                <div class="sales-title">
                    <el-row :gutter="21" v-if="this.$route.params.id == '123554'">
                        <el-col :span="6">
                            <el-form-item label="会员折扣">
                                <span>{{!form.sDiscount ? '--' : form.sDiscount}}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="21" v-if="this.$route.params.id == '123554'">
                        <el-col :span="6">
                            <el-form-item label="硬件合购优惠">
                                <span>{{form.sIsHardwareDiscount == 0 ? '无' : '会员服务与硬件特定配比'}}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="14">
                            <p class="b-text-last mr">( 注:此处硬件是指e直播、报平安和家校通。 )</p>
                        </el-col>
                    </el-row>
                    <el-row :gutter="21" v-if="this.$route.params.id == '123554'">
                        <el-col :span="6">
                            <el-form-item label="采购量">
                                <span>{{!form.sHardwareFrom ? '--' : form.sHardwareFrom}}</span>:<span>{{!form.sHardwareTo ? '--' :form.sHardwareTo}}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="14">
                            <p class="b-text-last mr">( 注:学习服务采购量：硬件服务采购量 )</p>
                        </el-col>
                    </el-row>
                    <el-row :gutter="21" v-if="this.$route.params.id == '123551'">
                        <el-col :span="6">
                            <el-form-item label="折扣条件">
                                <span>{{form.sIsDiscount == 0 ? '无' : '购买其他服务时优惠'}}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 会员的折扣 sDiscount  空中课堂的是 sIsDiscount-->
                    <el-row :gutter="21" v-if="this.$route.params.id == '123551'">
                        <el-col :span="6">
                            <el-form-item label="折扣">
                                <span>{{!form.sIsDiscount ? '不优惠' : form.sIsDiscount == 10 ? '不优惠' : form.sIsDiscount == 0 ? '赠送' : form.sIsDiscount}}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                     <el-row :gutter="21" v-else>
                        <el-col :span="6">
                            <el-form-item label="折扣">
                                <span>{{!form.sDiscount ? '不优惠' : form.sDiscount == 10 ? '不优惠' : form.sDiscount == 0 ? '赠送' : form.sDiscount}}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <div class="sales-title">
                    <span class="tip"></span>
                    <span class="title">编辑记录</span>
                </div>
                <div class='chart-trend'>
                    <el-table :data="tableData" style="width: 100%" v-loading ="tableLoading">
                        <el-table-column type="index" width="50" label="序号"></el-table-column>
                        <el-table-column prop="creatorName" label="操作人"></el-table-column>
                        <el-table-column prop="detail" label="操作内容"></el-table-column>
                        <el-table-column prop="createTime" label="操作时间"></el-table-column>
                    </el-table>
                    <div class="pagination-container" style="text-align:right">
                        <el-pagination
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="listQuery.total"
                            :current-page.sync="listQuery.page"
                            :page-sizes="config.pageSizes"
                            :page-size="config.pageSize"
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange">
                        </el-pagination>
                    </div>
                </div>
                <div class="footer">
                    <el-row type="flex" justify="center">
                        <el-col :span="2">
                            <el-button @click="cancel">返回</el-button>
                        </el-col>
                    </el-row>
                </div>
            </div>
        </el-form>
    </div>
</template>
<script>
import Levelbar from '../../layout/Levelbar';
import { mapState, mapActions, mapGetters } from 'vuex';
import {membershipServiceDetail, pageMembershipServiceLog} from 'api/newVipApi';
export default {
    name: 'editclassroom',
    components: { Levelbar },
    data() {
        return {
            tableLoading: false,
            loading: false,
            listQuery: {// 分页
                page: 1,
                total: 0
            },
            name: this.$route.params.name,
            form: {
                sBasePrice: [
                    {
                        price: ''
                    },
                    {
                        price: ''
                    },
                    {
                        price: ''
                    }
                ],
                sMarketPrice: [
                    {
                        price: ''
                    },
                    {
                        price: ''
                    },
                    {
                        price: ''
                    }
                ]
            },
            tableData: []
        };
    },
    computed: {
        ...mapState({
            config: state => state.config.table
        }),
        ...mapGetters([
            'uid'
        ])
    },
    created() {
        this.dataMembershipServiceDetail()
        this.searchFetchData()
    },
    methods: {
    // 全局获取行数
        ...mapActions(['ChangePageSize']),
    // 分页
        handleSizeChange(val) {
            this.listQuery.page = 1;
            this.tableLoading = true;
            this.ChangePageSize(val);
            this.searchFetchData();
        },
        handleCurrentChange(val) {
            this.tableLoading = true;
            this.listQuery.page = val;
            this.searchFetchData();
        },
        cancel() {
            this.$router.go(-1);
        },
        searchFetchData() {
            this.tableLoading = true;
            pageMembershipServiceLog(this.$route.params.id, this.listQuery.page, this.config.pageSize).then(data => {
                this.tableData = data.data.content.list;
                this.listQuery.total = data.data.content.pagination.total;
                this.tableLoading = false;
            }).catch(() => {
                this.tableLoading = false;
            })
        },
        dataMembershipServiceDetail() {
            this.loading = true
            membershipServiceDetail(this.$route.params.id).then(data => {
                this.form = data.data.content;
                this.loading = false;
                this.form.sBasePrice = JSON.parse(this.form.sBasePrice);
                this.form.sMarketPrice = JSON.parse(this.form.sMarketPrice);
            }).catch(() => {
                this.loading = false;
            })
        }
    }
};
</script>
<style lang="scss" scoped>
.mr{
    line-height: 35px;
}
.text-last{
    line-height: 35px;
    font-size: 14px;
    color: #666;
}
.b-text{
    color: #666;
    font-size: 14px;
    line-height: 1;
    padding: 11px 12px 11px 58px;
    box-sizing: border-box;
    margin-bottom: 30px;
}
.b-text-last{
    font-size:14px;
    font-family:MicrosoftYaHei;
    color:#FF5E2C;
    margin-left: 15px;
}
@mixin tip-css {
    display: inline-block;
    height: 14px;
    width: 4px;
    border-left: 3px solid #ff5e2c;
    padding-left: 10px;
    vertical-align: text-top;
}
.sales-title {
    margin-bottom: 40px;
    margin-top: 40px;
    .tip {
        @include tip-css();
    }
    .title {
        color: #333;
    }
}
.app-container {
    position: relative;
    padding: 20px 20px 10px;
    .app-levelbar {
        height: 35px;
    }
    .table{
        text-align:left;
        th,td{
            padding:0 20px;
            width:200px;
            height:40px;
            font-size:14px;
        }
        a{
            font-size:15px;
            color:#ff5e2c;
        }
    }
    .app-content{
        .box{
            padding:0 50px;
        }
        box-shadow:  0px 0px 5px 0px rgba(0, 0, 0, 0.1);
        -webkit-box-shadow:  0px 0px 5px 0px rgba(0, 0, 0, 0.1);
        background:#fff;
        padding-bottom:50px;
        .appTop{
            margin: 40px 0;
            font-size: 14px;
            color: #333;
            line-height: 14px;
            border-left: 4px solid #ff5e2c;
            text-indent: 16px;
        }
        .appTitle{
            padding-top:8px;
            text-align: center;
            font-size: 18px;
            color: #333;
            line-height: 72px;
            font-weight: bold;
            font-family: Microsoft YaHei;
            border-bottom: 1px solid #ddd;
        }
        
        .footer {
            text-align: center;
            margin-top: 60px;
        }
    }
    .dialog-footer{
        .el-button{
            margin: 80px 0 10px 0;
        }
        text-align: center;
    }
    .dialogTable{
        text-align:center;
        margin-left:50px;
        margin-top:30px;
        th{
            background:#f3f3f3;
        }
        th,td{
            text-align:center;
            padding:0 20px;
            border: solid 1px #ECECEC;
            width:220px;
            height:40px;
        }
    }
    .dialog-footer3{
        .el-button{
            margin: 50px 0 10px 0;
        }
        text-align: center;
    }
    .dialogTable3{
        text-align:center;
        margin-top:30px;
        margin:30px 50px;
        tr td:nth-of-type(1){
            width:30%;
        }
        tr td:nth-of-type(2){
            width:310px;
        }
        th,td{
            text-align:center;
            padding:0 20px;
            border: solid 1px #ECECEC;
            width:220px;
            height:40px;
        }
    }
    
}
</style>
